package mp.weixin.WXpublic.sendkefu;

import mp.weixin.WXpublic.BaseSendKefuMessage;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;

public class SKFVideoEntity extends BaseSendKefuMessage {

    private String mediaId;
    private String title;
    private String description;

    public SKFVideoEntity(String openId, String mediaId, String title, String description) {
        super(openId);
        this.mediaId = mediaId;
        this.title = title;
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    @Override
    public String toWeiXinKefuMessageJsonString() {
        ObjectNode jsono = new ObjectNode(JsonNodeFactory.instance);
        ObjectNode video = new ObjectNode(JsonNodeFactory.instance);
        video.put("media_id", this.getMediaId());
        video.put("thumb_media_id", this.mediaId);
        video.put("title", this.title);
        video.put("description", this.description);
        jsono.put("touser", this.getToUser());
        jsono.put("msgtype", getMsgType().getType());
        jsono.put(getMsgType().getType(), video);
        if (getKfAccount() != null && !getKfAccount().equals("")) {
            ObjectNode kf = new ObjectNode(JsonNodeFactory.instance);
            kf.put("kf_account", getKfAccount());
            jsono.put("customservice", kf);
        }
        return jsono.toString();
    }

    @Override
    public BaseSendKefuMessage.SendTypeEnum getMsgType() {
        return BaseSendKefuMessage.SendTypeEnum.VIDEO;
    }
}
